package j02tree;

import java.util.TreeSet;

class Man{
    String name;
    int age;

    public Man(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Man{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class J2 {
    public static void main(String[] args) {
        TreeSet<Man> arr = new TreeSet<>((m1,m2)->{
            if(m1.age!=m2.age){
                return m1.age - m2.age;
            }
            return m1.name.compareTo(m2.name);
        });
        arr.add(new Man("aluxn",45));
        arr.add(new Man("zlibai",7));
        arr.add(new Man("ylibai",7));
        arr.add(new Man("mqing",17));

        System.out.println("arr = " + arr);
    }
}
